package com.zx.controller;

import com.zx.res.ResponseResult;
import com.zx.service.OrderService;
import com.zx.service.UserService;
import com.zx.vo.UserOrderVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/v1/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    @Autowired
    private UserService userService;

    @GetMapping("/list")
    public ResponseResult getList(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "5") Integer pers){
        Map<String, Object> map = orderService.getAllOrder(page, pers);
        return new ResponseResult(10000,"操作成功",map);
    }

    @GetMapping("/userProduct")
    public ResponseResult userProduct(){
        List<UserOrderVo> userProduct = userService.getAllUserProduct();
        return new ResponseResult(10000,"操作成功",userProduct);
    }

}
